﻿using System;
using System.Drawing;
using MUnit;

namespace Maze
{
    class TestCollision
    {
        private SQ[,] squares = {{ SQ.W, SQ.O },
                                 { SQ.O, SQ.O }};
        private Board board;
        private Player player;
        private DumbEnemy enemy;

        private Point startSquare = new Point(1, 0);

        [Setup]
        void Setup()
        {
            // This will be run once before each test method
            this.board = new Board(this.squares);
            this.player = new Player(this.startSquare, new PathFinder(this.board));
            this.player.GoToSquare(new Point(1, 1));
            this.enemy = new DumbEnemy(new Point(0, 1), new PathFinder(this.board), this.startSquare);
        }

        [Test]
        void PlayerDoesNotCollideWithEnemy()
        {
            this.player.Update(10, this.board);
            this.enemy.Update(10);

            Verify.Assert(!this.player.CollidesWith(this.enemy));
        }

        [Test]
        void PlayerDoesNotCollideWhenEnemyAdjecent()
        {
            this.enemy.Update(1);

            Verify.Assert(!this.player.CollidesWith(this.enemy));
        }

        [Test]
        void PlayerCollidesWithEnemy()
        {
            this.player.Update(2, this.board);
            this.enemy.Update(2);

            Verify.Assert(this.player.CollidesWith(this.enemy));
        }

        [Test]
        void PlayerCollidesWithEnemyAgain()
        {
            this.enemy.Update(1);
            this.enemy.Update(10);

            Verify.Assert(this.player.CollidesWith(this.enemy));
        }

        [TearDown]
        void TearDown()
        {
            // This will be run once after each test method
        }
    }
}
